package main

import (
	"fmt"
	"sync"
)

func double(s []int) {
	for i, v := range s {
		s[i] = v * 2
	}
}

func double1(s []int, wg *sync.WaitGroup) {
	defer wg.Done()
	for i, v := range s {
		s[i] = v * 2
	}
}

func calc(slice []int) {
	var wg = new(sync.WaitGroup)
	wg.Add(3)
	go double1(slice[:100000000], wg)
	go double1(slice[100000000:200000000], wg)
	go double1(slice[200000000:], wg)
	wg.Wait()
}

func main() {
	var s = []int{}
	for i := 0; i < 300000000; i++ {
		s = append(s, i)
	}
	// double(slice)
	calc(s)
	fmt.Println(s[200000000])
}
